﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace TudienOnline
{
    public partial class _Default : System.Web.UI.Page
    {
        private String sCnnStr = ConfigurationManager.ConnectionStrings["cnTudienOnline"].ToString();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                ddlTudien_napDulieu();//0908081979
            }
        }
        private void ddlTudien_napDulieu()
        {
            SqlConnection cn = null;
            SqlCommand cm = null;
            SqlDataAdapter da = null;
            DataSet ds = null;
            try
            {
                cn = new SqlConnection(sCnnStr);
                cm = new SqlCommand("spTudien_getbyID", cn);
                cm.CommandType = CommandType.StoredProcedure;
                int TudienID = 0;
                cm.Parameters.Add(new SqlParameter("@PK_iTudienID",TudienID));
                da = new SqlDataAdapter(cm);
                ds = new DataSet();
                da.Fill(ds);
                if (ds.Tables.Count > 0&&ds.Tables[0].Rows.Count>0) {
                    ddlTudien.DataSource = ds;
                    ddlTudien.DataTextField = "sTudien";
                    ddlTudien.DataValueField = "PK_iTudienID";
                    ddlTudien.DataBind();
                }
            }
            catch
            {

            }
            finally {
                cn.Close();
                cn.Dispose();
                cm.Dispose();
                da.Dispose();
            }
        }
    }
}
